<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<ui:composition template="/template/mainTemplate.xhtml">
	<ui:define name="titulo">
		<h:outputLabel value="#{msg.editar} #{msg.user}" />
	</ui:define>
	<ui:define name="cont">
		<p:messages />
		<p:panel id="painelCadastro" header="#{msg.editar} #{msg.user} - MusicBay">
			<h:form>
				<h:panelGrid columns="3" cellpadding="7">
					<h:outputLabel value="#{msg.nome}" for="nome" class="label" />
					<h:panelGroup>
						<p:inputText value="#{contextoManagedBean.userSession.nome}" id="nome" label="#{msg.name}"
							required="true" size="30" maxlength="30" requiredMessage="#{msg.nome} #{msg.naoInformado}">
							<f:validateLength minimum="2" maximum="30" />
						</p:inputText>
					</h:panelGroup>
					<p:message for="nome" />

					<h:outputLabel value="#{msg.unome}" for="sobrenome" class="label" />
					<h:panelGroup>
						<p:inputText value="#{contextoManagedBean.userSession.sobrenome}" id="sobrenome"
							label="#{msg.unome}" required="true" size="60"
							requiredMessage="#{msg.unome} #{msg.naoInformado}">
							<f:validateLength minimum="2" />
						</p:inputText>
					</h:panelGroup>
					<p:message for="sobrenome" />

					<h:outputLabel value="#{msg.nascimento}" for="ptCal" class="label" />
					<h:panelGroup>
						<p:calendar locale="pt" showButtonPanel="true" navigator="true" id="ptCal" required="true"
							yearRange="1900" pattern="dd/MM/yyyy" value="#{contextoManagedBean.userSession.nascimento}"
							requiredMessage="#{msg.invalido}: #{msg.nascimento}">
						</p:calendar>
					</h:panelGroup>
					<p:message for="ptCal" />

					<h:outputLabel value="#{msg.sexo}" for="sexo" class="label" />
					<h:panelGroup>
						<p:selectOneRadio value="#{contextoManagedBean.userSession.sexo}" id="sexo"
							label="#{msg.sexo}" required="true" requiredMessage="#{msg.sexo} #{msg.naoInformado}"
							styleClass="label">
							<f:selectItem itemLabel="#{msg.masculino}" itemValue="M" />
							<f:selectItem itemLabel="#{msg.feminino}" itemValue="F" />
						</p:selectOneRadio>
					</h:panelGroup>
					<p:message for="sexo" />

					<h:outputLabel value="CPF" for="cpf" class="label" />
					<h:panelGroup>
						<p:inputMask value="#{contextoManagedBean.userSession.cpf}" mask="999.999.999-99" id="cpf"
							label="CPF" required="true" size="15" requiredMessage="CPF #{msg.naoInformado}"
							readonly="true">
							<f:validator for="cpf" validatorId="validatorCpf" />
						</p:inputMask>
					</h:panelGroup>
					<p:message for="cpf" />

					<h:outputLabel value="E-mail" for="email" class="label" />
					<h:panelGroup>
						<p:inputText value="#{contextoManagedBean.userSession.email}" id="email" label="email"
							size="25" required="true" requiredMessage="#{msg.invalido}: E-mail}" readonly="true">
							<f:validateRegex pattern="[a-zA-Z0-9\-\_\.]+@[a-zA-Z0-9\-\_\.]+" />
							<f:validator for="email" validatorId="validatorEmail" />
						</p:inputText>
					</h:panelGroup>
					<p:message for="email" />

					<h:outputLabel value="Login" for="login" class="label" />
					<h:panelGroup>
						<p:inputText value="#{contextoManagedBean.userSession.login}" id="login" label="login"
							required="true" size="23" requiredMessage="Login #{msg.naoInformado}" readonly="true">
							<f:validator for="login" validatorId="validatorLogin" />
						</p:inputText>
					</h:panelGroup>
					<p:message for="login" />

					<h:outputLabel value="Imagem" class="label" />
					<h:form enctype="multipart/form-data">
						<p:fileUpload fileUploadListener="#{fileUploadController.handleFileUpload}" mode="advanced"
							update="messages" multiple="false" allowTypes="/(\.|\/)(gif|jpe?g|png|JGP)$/"
							styleClass="upload" auto="true" sizeLimit="30000">
						</p:fileUpload>
						<p:growl id="messages" showDetail="true" />
					</h:form>

					<h:outputLabel value="" />
					<h:outputLabel value="#{msg.senha}" for="senha1" class="label" />
					<h:panelGroup>
						<p:password id="senha1" value="#{contextoManagedBean.userSession.senha}" match="senha2"
							label="senha1" required="true" requiredMessage="#{msg.informe} #{msg.senha}" />
					</h:panelGroup>
					<p:message for="senha1" />

					<h:outputLabel value="#{msg.repita} #{msg.senha}" for="senha2" class="label" />
					<h:panelGroup>
						<p:password id="senha2" value="#{contextoManagedBean.userSession.senha}" label="senha2"
							required="true" requiredMessage="#{msg.repita} #{msg.senha}" />
					</h:panelGroup>
					<p:message for="senha2" />
				</h:panelGrid>

				<p:commandButton id="showceditDialog" value="#{msg.concluir} #{msg.edicao}"
					oncomplete="editDialog.show()" />

				<p:confirmDialog id="editDialog" message="#{msg.confirma} #{msg.edicao}?"
					header="#{msg.editar} #{msg.user}?" severity="alert" widgetVar="editDialog">

					<p:commandButton id="confirmar" value="#{msg.confirma}" ajax="false"
						actionListener="#{contextoManagedBean.actionUpdate}" oncomplete="editDialog.hide()">
						<f:attribute name="img" value="#{fileUploadController.by}" />
					</p:commandButton>
					<p:commandButton id="cancelar" value="#{msg.cancelar}" onclick="editDialog.hide()"
						type="button" />
				</p:confirmDialog>
			</h:form>
		</p:panel>
	</ui:define>
</ui:composition>
</html>